#define _CRT_SECURE_NO_WARNINGS 1


//int removeElement(int* nums, int numsSize, int val)
//{
//	//定义两个变量
//	int src = 0, dst = 0;
//
//	while (src < numsSize)
//	{
//		//nums[src] == val,src++
//		//否则赋值,src和dst都++
//		if (nums[src] == val)
//		{
//			src++;
//		}
//		else
//		{
//			//说明src指向位置的值不等于val
//			nums[dst] = nums[src];
//			dst++;
//			src++;
//		}
//	}
//
//	//此时dst的值刚好是数组的新长度
//	return dst;
//}




//void merge(int* nums1, int nums1Size, int m, int* nums2, int nums2Size, int n)
//{
//	int l1 = m - 1;
//	int l2 = n - 1;
//	int l3 = m + n - 1;
//
//	while (l1 >= 0 && l2 >= 0)
//	{
//		//从后往前比大小
//		if (nums1[l1] > nums2[l2])
//		{
//			nums1[l3--] = nums1[l1--];
//		}
//		else
//		{
//			nums1[l3--] = nums2[l2--];
//		}
//	}
//
//	//要么是l1 < 0，要么是l2 < 0
//	while (l2 >= 0)
//	{
//		nums1[l3--] = nums2[l2--];
//	}
//}



#include "SList.h"

void SListTest01()
{
	//一般不会这样去创建链表，这里只是为了给大家展示链表的打印
	SLTNode* node1 = (SLTNode*)malloc(sizeof(SLTNode));
	node1->data = 1;
	SLTNode* node2 = (SLTNode*)malloc(sizeof(SLTNode));
	node2->data = 2;
	SLTNode* node3 = (SLTNode*)malloc(sizeof(SLTNode));
	node3->data = 3;
	SLTNode* node4 = (SLTNode*)malloc(sizeof(SLTNode));
	node4->data = 4;

	node1->next = node2;
	node2->next = node3;
	node3->next = node4;
	node4->next = NULL;

	SLTNode* plist = node1;
	SLTPrint(plist);
}

void SListTest02()
{
	SLTNode* plist = NULL;
	SLTPushBack(&plist, 1);
	SLTPushBack(&plist, 2);
	SLTPushBack(&plist, 3);
	SLTPushBack(&plist, 4);
	SLTPrint(plist);

	//SLTPushBack(NULL, 5);

	//SLTPushFront(&plist, 5);
	//SLTPrint(plist);
	//SLTPushFront(&plist, 6);
	//SLTPrint(plist);
	//SLTPushFront(&plist, 7);
	//SLTPrint(plist);

	SLTPopBack(&plist);
	SLTPrint(plist);
	SLTPopBack(&plist);
	SLTPrint(plist);
	SLTPopBack(&plist);
	SLTPrint(plist);
	SLTPopBack(&plist);
	SLTPrint(plist);
	//SLTPopBack(&plist);
	//SLTPrint(plist);
}

void SListTest03()
{
	SLTNode* plist = NULL;
	SLTPushBack(&plist, 1);
	SLTPushBack(&plist, 2);
	SLTPushBack(&plist, 3);
	SLTPushBack(&plist, 4);
	SLTPrint(plist);

	//头删
	//SLTPopFront(&plist);
	//SLTPrint(plist);
	//SLTPopFront(&plist);
	//SLTPrint(plist);
	//SLTPopFront(&plist);
	//SLTPrint(plist);
	//SLTPopFront(&plist);
	//SLTPrint(plist);
	////SLTPopFront(&plist);
	////SLTPrint(plist);

	//SLTNode* FindRet = SLTFind(&plist, 3);

	////if (FindRet)
	////{
	////	printf("找到了！\n");
	////}
	////else
	////{
	////	printf("未找到！\n");
	////}

	////SLTInsert(&plist, FindRet, 100);
	////SLTPrint(plist);

	////SLTInsertAfter(FindRet, 100);
	////SLTPrint(plist);

	////删除指定位置的节点
	//SLTErase(&plist, FindRet);
	//SLTPrint(plist);

	SListDesTroy(&plist);
}


int main()
{
	//SListTest01();
	//SListTest02();
	SListTest03();

	return 0;
}